<template>
	<view class="diseaseDetail">
		<Navigation title="疾病自查" background="#fff" />
		<view class="w-f h-80 type-box">
			<u-tabs :list="typeList" @click="changeType" lineColor="#FABB3C"
				:activeStyle="{ fontSize: '28rpx', color: '#222222', fontWeight: '600' }"
				:inactiveStyle="{ fontSize: '28rpx', color: '#999999' }"
				:itemStyle="{ width: '50%', lineHeight: '80rpx' }" :current="type"></u-tabs>
		</view>
		<Dog v-show="type == 0" :name="name" :petId="petId" ref="pageListDog" />
		<Cat v-show="type == 1" :name="name" :petId="petId" ref="pageListCat" />
	</view>
</template>
<script setup lang="ts">
	import { ref } from 'vue';
	import { onLoad } from '@dcloudio/uni-app';
	import Dog from './Dog.vue';
	import Cat from './Cat.vue';
	import { diseasePage } from '@/services/api/index/index';
	const type = ref(0);
	const typeList = [{ name: '汪星人' }, { name: '喵星人' }];
	const name = ref('');
	const firstCategoryId = ref<string>('');
	const lists = ref([]);
	const pageListDog = ref('');
	const pageListCat = ref('');
	const petId = ref('')
	onLoad((options : any) => {
		name.value = options.name;
		petId.value = options.petId
		firstCategoryId.value = options.firstCategoryId;
		if (firstCategoryId.value == '28') {
			type.value = 0;
		} else {
			type.value = 1;
		}
		getList()
	});
	const changeType = (data : any) => {
		type.value = data.index;
		if (data.index == 0) {
			firstCategoryId.value = 11;
		} else {
			firstCategoryId.value = 10;
		}
		getList();
	};
	async function getList() {
		const { data } = await diseasePage({
			pageNo: 1,
			pageSize: 10,
			firstCategoryCode: firstCategoryId.value,
		});
		// lists.value = data.list

		pageListDog.value.getDataDog(data.list)
		pageListCat.value.getDataCat(data.list)
	}
</script>
<style lang="scss" scoped>
	.diseaseDetail {
		background: #f5f5f5;
		min-height: 100vh;

		.type-box {
			background: #fff;
		}
	}
</style>